package GraphicView;



import ikelib.menuUtil;
import ikelib.wintime;
import ikeuilib.JButtonWithMenu;

import javax.swing.JPanel;

import java.awt.Checkbox;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.BoxLayout;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.ListCellRenderer;

import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.PrinterJob;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JSlider;
import javax.swing.JInternalFrame;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;

import java.awt.GridBagLayout;
import java.awt.FlowLayout;
import javax.swing.SwingConstants;

import spectrum.SpectrumView;
import wcg.winDataBase;
import wcg.winchkgPanelInterface;
import wcg.winchkgProperty;
import javax.swing.JProgressBar;
import java.awt.GridLayout;
import java.awt.Insets;
import javax.swing.border.EmptyBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.border.BevelBorder;
import javax.swing.border.MatteBorder;
import java.awt.Font;

public class GraphicViewPanel extends JPanel implements MenuListener, ActionListener, winchkgPanelInterface, ItemListener  {

	//private winchkg Parent=null;
	private ItemListener Parent=null;
	
	private ArrayList<String> MyFavotiteAmplitude = new ArrayList<String>();  //  @jve:decl-index $hide$=0:
	private static final long serialVersionUID = 1L;
	private JLabel jLabelInfo1 = null;
	private JPanel jPanelControl = null;
	public JCheckBox jCheckBoxRcvUdp = null;
	private JLabel jLabelPort = null;
	public JTextField jTextFieldPort = null;
	public JCheckBox jCheckBoxWriteFile = null;
	public JTextField jTextFieldWriteFileDir = null;
	private GraphicView GraphicView=null;//@
	public JCheckBox jCheckBoxAutoDisplay = null;
	private JCheckBox jCheckBoxAutoTrack = null;
	private JLabel jLabelTimeGroupe = null;
	private JLabel jLabelAmplitudeGroupe = null;
	private JButton jButtonAutoScale = null;
	private JButtonWithMenu jButtonSingleScale = null;
	private JButton jButtonChInc = null;
	private JButton jButtonChDec = null;
	private JButton jButtonChDispShiftUp = null;
	private JButton jButtonChDispShiftDown = null;
	private JButton jButtonTimeDec = null;
	private JButton jButtonTimeInc = null;
	private JButton jButtonTimePageDec = null;
	private JButton jButtonTimePageInc = null;
	private JButton jButtonZoomOut = null;
	private JButton jButtonZoomIn = null;
	private JComboBox jComboBoxSpan = null;
	private JLabel jLabelDispTime = null;
	private JLabel  jLabelDispSpan = null;
	private JLabel jLabelChannelInfo = null;
	private JLabel jLabelChannelGroupe = null;
	private JButton jButtonAmpInc = null;
	private JButton jButtonAmpDec = null;
	private JCheckBox jCheckBoxOffsetZero = null;
	private JButton jButtonSnapShot = null;
	private JButton jButtonClear = null;
	private winDataBase DataBase=null;  //  @jve:decl-index $hide$=0: $hide$
	private JButtonWithMenu jButtonChannelConfig = null;
	private JButton jButtonChDispPageUp = null;
	private JButton jButtonChDispPageDown = null;
	private JLabel jLabelZoom = null;
	private JPanel jPanelSouth = null;
	private JLabel jLabelTime = null;
	
	private JToolBar jToolBarTest = null;
	private JToolBar jToolBarTest2 = null;
	private JComboBox jComboBoxDrawMode = null;
	private JPanel jPanelWest = null;
	private JLabel jLabelSpace = null;
	private JLabel jLabelDisplayGroup = null;
	private JPanel jPanelEast = null;
	private JLabel jLabelLogo = null;
	
	
	private static String[] FormatAmplitudeString  = { "1","1.2","1.23","1.234","1.2345", "1e-02","1.2e-03","1.23e-04", "1.234e-05","1.2345e-06", "1.23456e-07", "1.234567e-08","1.2345678e-09" };
	private static String[] FormatAmplitudeFormat = { "%.0f","%.1f","%.2f","%.3f","%.4f","%.0e","%.1e","%.2e", "%.3e" , "%.4e" , "%.5e" , "%.6e" , "%.7e" ,"%.7e"};
	private  int FORMAT_AMPLITUDE_MAX = FormatAmplitudeString.length;
	private JRadioButtonMenuItem[] FormatAmplitudeMenuItem = new JRadioButtonMenuItem[FORMAT_AMPLITUDE_MAX];

	
	
	
	public winchkgProperty  Prop = null;
	private JCheckBoxMenuItem showChannelInfo;
	private JCheckBoxMenuItem showChannelNumber;
	private JCheckBoxMenuItem showStation;
	private JCheckBoxMenuItem showComponent;
	private JCheckBoxMenuItem showAmpAxis;
	private JCheckBoxMenuItem showTimeSamplePoint;
	private JCheckBoxMenuItem clipRect;
	private JCheckBoxMenuItem showCursorTime;
	private JCheckBoxMenuItem showAmpLabel;
	private JRadioButtonMenuItem colorBWBlack;
	private JRadioButtonMenuItem colorBWWhite;
	private JRadioButtonMenuItem colorColorBlack;
	private JRadioButtonMenuItem colorColorWhite;
	private JRadioButtonMenuItem colorMapByChannel;
	private JRadioButtonMenuItem colorMapByStation;
	private JRadioButtonMenuItem colorMapByComponent;
	private JPanel panel_4;
	private JProgressBar pBMemory;
	
	//public void setParent(winchkg pa){
	public void setParent(ItemListener pa){
		Parent = pa;
		//Prop = pa.Prop;
	}
	public void setProperty(winchkgProperty p){
		Prop = p;
	}

	
	/**
	 * 
	 * @param db
	 */
	public void setWinDataBase(winDataBase db){
		DataBase = db;
		jTextFieldWriteFileDir.setText(DataBase.getWriteOutFolder());
	}
	/**
	 * This is the default constructor
	 */
	public GraphicViewPanel() {
		super();
		initialize();
		this.add(getGraphicView(),BorderLayout.CENTER);//@jve:decl-index $hide$=0 $hide$
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(654, 669);
		this.setLayout(new BorderLayout());
		this.add(getJPanelControl(), BorderLayout.WEST);
		this.add(getJPanelSouth(), BorderLayout.SOUTH);
	}

	public GraphicView getGraphicView(){
		if(GraphicView==null){
			GraphicView = new GraphicView();
			GraphicView.ParentPanel=this; 
		}
		return GraphicView;
	}
	/**
	 * This method initializes jPanelControl	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanelControl() {
		if (jPanelControl == null) {
			jLabelLogo = new JLabel();
			jLabelLogo.setBounds(new Rectangle(7, 7, 133, 44));
			jLabelLogo.setText("");
			jLabelLogo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/hakusan_130.png")));
			jPanelControl = new JPanel();
			jPanelControl.setBorder(new EmptyBorder(0, 0, 0, 0));
			
			jPanelControl.setPreferredSize(new Dimension(152, 450));
			jPanelControl.setLayout(null);
			jPanelControl.add(jLabelLogo, null);
			
			JPanel panel = new JPanel();
			panel.setBorder(new TitledBorder(null, "Channel", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			panel.setBounds(0, 400, 148, 107);
			jPanelControl.add(panel);
			panel.setLayout(null);
			panel.add(getJButtonChannelConfig());
			panel.add(getJButtonChDispPageDown());
			panel.add(getJButtonChDispPageUp());
			panel.add(getJButtonChDispShiftUp());
			panel.add(getJButtonChDispShiftDown());
			panel.add(getJButtonChInc());
			panel.add(getJButtonChDec());
			jLabelChannelInfo = new JLabel();
			jLabelChannelInfo.setHorizontalAlignment(SwingConstants.CENTER);
			jLabelChannelInfo.setBounds(14, 25, 51, 21);
			panel.add(jLabelChannelInfo);
			jLabelChannelInfo.setText("0/0");
			jLabelChannelInfo.setBorder(new LineBorder(Color.lightGray,1,true));
			
			JPanel panel_1 = new JPanel();
			panel_1.setBorder(new TitledBorder(null, "Time", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			panel_1.setBounds(0, 231, 148, 162);
			jPanelControl.add(panel_1);
			panel_1.setLayout(null);
			jLabelTime = new JLabel();
			jLabelTime.setBounds(7, 22, 133, 19);
			panel_1.add(jLabelTime);
			jLabelTime.setText("display time");
			jLabelTime.setFont(getFont().deriveFont(10.0f));
			jLabelTime.setBorder(new LineBorder(Color.lightGray,1,true));
			panel_1.add(getJButtonTimePageDec());
			panel_1.add(getJButtonTimeDec());
			panel_1.add(getJButtonTimeInc());
			panel_1.add(getJButtonTimePageInc());
			panel_1.add(getJButtonZoomOut());
			panel_1.add(getJButtonZoomIn());
			panel_1.add(getJComboBoxSpan());
			panel_1.add(getJCheckBoxAutoDisplay());
			
			JButton btnAutoTime = new JButton("");
			btnAutoTime.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/arrow_left_end.png")));
			btnAutoTime.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					GraphicView.doTimeAuto();
				}
			});
			btnAutoTime.setBounds(8, 44, 20, 20);
			panel_1.add(btnAutoTime);
			
			jLabelDispSpan = new JLabel("Span");
			jLabelDispSpan.setBounds(9, 69, 78, 18);
			panel_1.add(jLabelDispSpan);
			
			JPanel panel_2 = new JPanel();
			panel_2.setBorder(new TitledBorder(null, "Amplitude", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			panel_2.setBounds(0, 102, 148, 131);
			jPanelControl.add(panel_2);
			panel_2.setLayout(null);
			panel_2.add(getJButtonAutoScale());
			panel_2.add(getJButtonAmpDec());
			panel_2.add(getJButtonSingleScale());
			panel_2.add(getJButtonAmpInc());
			panel_2.add(getJCheckBoxOffsetZero());
			panel_2.add(getJCheckBoxAutoTrack());
			
			JPanel panel_3 = new JPanel();
			panel_3.setBorder(new TitledBorder(null, "Display", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			panel_3.setBounds(0, 50, 148, 58);
			jPanelControl.add(panel_3);
			panel_3.setLayout(null);
			panel_3.add(getJComboBoxDrawMode());
			jPanelControl.add(getPanel_4());
			jLabelTime.addMouseListener(new java.awt.event.MouseAdapter() {
				public void mouseClicked(java.awt.event.MouseEvent e) {
					GraphicView.doTimeSetDialog();
				}
			});
			jLabelChannelInfo.addMouseListener(new java.awt.event.MouseAdapter() {
				public void mouseClicked(java.awt.event.MouseEvent e) {
					String inputValue = JOptionPane.showInputDialog("Set display channel");
					if(inputValue!=null){
						try{
							int cn = Integer.valueOf(inputValue);
							if(cn>0){
								GraphicView.setShowChannel(cn);
							}
						} catch(NumberFormatException ne){
							// nothing to do
						}
						
					}
				}
			});
		}
		return jPanelControl;
	}

	/**
	 * This method initializes jCheckBoxRcvUdp	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	private JCheckBox getJCheckBoxRcvUdp() {
		if (jCheckBoxRcvUdp == null) {
			jCheckBoxRcvUdp = new JCheckBox();
			jCheckBoxRcvUdp.setBounds(15, 25, 121, 22);
			jCheckBoxRcvUdp.setText("Receive UDP");
			jCheckBoxRcvUdp.setToolTipText("Receive win A0 udp packet or ACT");
			jCheckBoxRcvUdp.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					if(jCheckBoxRcvUdp.isSelected()) jTextFieldPort.setEditable(false);
					else jTextFieldPort.setEditable(true);
					Parent.itemStateChanged(e);
				}
			});
		}
		return jCheckBoxRcvUdp;
	}

	/**
	 * This method initializes jTextFieldPort	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextFieldPort() {
		if (jTextFieldPort == null) {
			jTextFieldPort = new JTextField();
			jTextFieldPort.setBounds(56, 48, 73, 22);
			jTextFieldPort.setToolTipText("Receive port");
		}
		return jTextFieldPort;
	}

	/**
	 * This method initializes jCheckBoxWriteFile	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	private JCheckBox getJCheckBoxWriteFile() {
		if (jCheckBoxWriteFile == null) {
			jCheckBoxWriteFile = new JCheckBox();
			jCheckBoxWriteFile.setText("Write File");
			jCheckBoxWriteFile.setToolTipText("Folder to write files");
			jCheckBoxWriteFile.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					Parent.itemStateChanged(e);
					if(jCheckBoxWriteFile.isSelected()){
						jTextFieldWriteFileDir.setEditable(false);
						jTextFieldWriteFileDir.setEnabled(false);
					}
					else{
						jTextFieldWriteFileDir.setEditable(true);
						jTextFieldWriteFileDir.setEnabled(true);
					}
				}
			});
		}
		return jCheckBoxWriteFile;
	}

	/**
	 * This method initializes jTextFieldWriteFileDir	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	public JTextField getJTextFieldWriteFileDir() {
		if (jTextFieldWriteFileDir == null) {
			jTextFieldWriteFileDir = new JTextField();
			jTextFieldWriteFileDir.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
			jTextFieldWriteFileDir.setMinimumSize(new Dimension(10, 16));
			jTextFieldWriteFileDir.setPreferredSize(new Dimension(280, 16));
			jTextFieldWriteFileDir.setToolTipText("Directory for write win file");
			String mes = "Edit or double click to change.This folder is used as the default save folder for other operation that needs to save files.";
			jTextFieldWriteFileDir.setToolTipText(jTextFieldWriteFileDir.getText()+mes);
			jTextFieldWriteFileDir.addMouseListener(new java.awt.event.MouseAdapter() {
				public void mouseClicked(java.awt.event.MouseEvent e) {
					if(DataBase!=null && jTextFieldWriteFileDir.isEnabled()){
						String initPath = new String(jTextFieldWriteFileDir.getText());
						if(initPath.length()>=1){
							if(initPath.charAt(initPath.length()-1) != File.separatorChar){
								initPath += File.separator;
							}
						}
						JFileChooser filechooser = new JFileChooser(initPath);
						filechooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );	      
						filechooser.setDialogTitle("Save folder");
						int selected = filechooser.showSaveDialog(null);
						if ( selected == JFileChooser.APPROVE_OPTION ) {
							File file = filechooser.getSelectedFile ();
							String dirPath = file.getAbsolutePath();
							boolean flag = true;
							File tmpfile=new File(dirPath+File.separator+"temp.tmp");
							try {
								tmpfile.createNewFile();
							} catch (IOException e1) {
								flag=false;
							}
							if(!flag){
								JOptionPane.showMessageDialog(null, "Cannot create file in this folder.\n" + dirPath);
							}
							else{
								tmpfile.delete();
								jTextFieldWriteFileDir.setText(dirPath);
								DataBase.setWriteOutFolder(jTextFieldWriteFileDir.getText());
							}
						}
					}
				}
			});
		}
		return jTextFieldWriteFileDir;
	}

	/**
	 * This method initializes jCheckBoxAutoDisplay	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	private JCheckBox getJCheckBoxAutoDisplay() {
		if (jCheckBoxAutoDisplay == null) {
			jCheckBoxAutoDisplay = new JCheckBox();
			jCheckBoxAutoDisplay.setFont(new Font("Dialog", Font.BOLD, 12));
			jCheckBoxAutoDisplay.setBounds(7, 127, 135, 21);
			jCheckBoxAutoDisplay.setText("Show Latest");
			jCheckBoxAutoDisplay.setToolTipText("Show latest automatically");
			jCheckBoxAutoDisplay.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					//Parent.itemStateChanged(e);
					GraphicView.AutoDisplay = jCheckBoxAutoDisplay.isSelected(); 
				}
			});
		}
		return jCheckBoxAutoDisplay;
	}

	/**
	 * This method initializes jCheckBoxAutoTrack	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	private JCheckBox getJCheckBoxAutoTrack() {
		if (jCheckBoxAutoTrack == null) {
			jCheckBoxAutoTrack = new JCheckBox();
			jCheckBoxAutoTrack.setBounds(15, 95, 102, 24);
			jCheckBoxAutoTrack.setText("Auto Track");
			jCheckBoxAutoTrack.setToolTipText("Adjust amplitude scale always automatically");
			jCheckBoxAutoTrack.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					GraphicView.setAutoTrack(jCheckBoxAutoTrack.isSelected());
				}
			});
		}
		return jCheckBoxAutoTrack;
	}

	/**
	 * This method initializes jButtonAutoScale	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonAutoScale() {
		if (jButtonAutoScale == null) {
			jButtonAutoScale = new JButton();
			jButtonAutoScale.setBounds(6, 24, 85, 25);
			jButtonAutoScale.setHorizontalAlignment(SwingConstants.LEFT);
			jButtonAutoScale.setText("Auto");
			jButtonAutoScale.setToolTipText("Adjust amplitude scale (A)");
			jButtonAutoScale.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doAutoScale();

				}
			});
		}
		return jButtonAutoScale;
	}

	/**
	 * This method initializes jButtonSingleScale	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonSingleScale() {
		if (jButtonSingleScale == null) {
			jButtonSingleScale = new JButtonWithMenu();
			jButtonSingleScale.setBounds(6, 52, 85, 25);
			jButtonSingleScale.setHorizontalAlignment(SwingConstants.LEFT);
			jButtonSingleScale.setText("Single");
			jButtonSingleScale.setToolTipText("Adjust amplitude scale to single scale (S)");
			jButtonSingleScale.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					// メニュー領域が押された
					if(jButtonSingleScale.isClickedDropDown()){
						JPopupMenu popup=new JPopupMenu();
						JMenuItem mi = new JMenuItem("Sigle Scale");
						mi.addActionListener(new ActionListener(){
							@Override
							public void actionPerformed(ActionEvent arg0) {
								GraphicView.doSingleScale();
							}
							
						});
				        popup.add(mi);
				        popup.addSeparator();
				        
						JMenuItem mi2 = new JMenuItem("My scale...");
						mi2.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/add.png")));
						mi2.addActionListener(new ActionListener(){
							@Override
							public void actionPerformed(ActionEvent arg0) {
								try{
//									String s;
//									if(MyFavotiteAmplitude.isEmpty()) s="";
//									else s = MyFavotiteAmplitude.get(0);
									String imp = JOptionPane.showInputDialog(null,"expl. 20 (digit) , 1e2 gal ","Enter scale (p-p)",JOptionPane.PLAIN_MESSAGE);
									if(imp==null) return;
									if(!doMyScale(imp)){
										return;
									}
									for(int i=0;i<MyFavotiteAmplitude.size();i++){
										String ss = MyFavotiteAmplitude.get(i);
										if(ss.equals(imp)){
											MyFavotiteAmplitude.remove(i);
											break;
										}
									}
									MyFavotiteAmplitude.add(0,imp);
									if(MyFavotiteAmplitude.size()>5) MyFavotiteAmplitude.remove(5);
								} catch(NumberFormatException e){
									
								}
							}
						});
				        popup.add(mi2);
				        for(int i=0;i<MyFavotiteAmplitude.size();i++){
				        	JMenuItem mi3 = new JMenuItem(MyFavotiteAmplitude.get(i));
							mi3.addActionListener(new ActionListener(){
								@Override
								public void actionPerformed(ActionEvent arg0) {
									try{
										String cmd = arg0.getActionCommand();
										doMyScale(cmd);
//										long val = Long.valueOf(cmd);
//										if(val<=0) return;
//										GraphicView.doSingleScale(val);
									}catch(NumberFormatException e){
										
									}
								}
							});		
							popup.add(mi3);
				        }
				        
				        
				        popup.show(jButtonSingleScale,0,jButtonSingleScale.getHeight());
						
					}
					else{
						GraphicView.doSingleScale();
					}
				}
			});
		}
		return jButtonSingleScale;
	}

	/**
	 * This method initializes jButtonChInc	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonChInc() {
		if (jButtonChInc == null) {
			jButtonChInc = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/plus.gif")));
			jButtonChInc.setBounds(13, 47, 20, 20);
			jButtonChInc.setToolTipText("Increment the number of displayed channel (Inc)");
			jButtonChInc.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doChannelInc();
				}
			});
		}
		return jButtonChInc;
	}

	/**
	 * This method initializes jButtonChDec	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonChDec() {
		if (jButtonChDec == null) {
			jButtonChDec = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/minus.gif")));
			jButtonChDec.setBounds(45, 47, 20, 20);
			jButtonChDec.setToolTipText("Decrement the number of displayed channel (Del)");
			jButtonChDec.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doChannelDec();
				}
			});
		}
		return jButtonChDec;
	}

	/**
	 * This method initializes jButtonChDispShiftUp	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonChDispShiftUp() {
		if (jButtonChDispShiftUp == null) {
			jButtonChDispShiftUp = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/arrow_up.png")));
			jButtonChDispShiftUp.setBounds(110, 26, 20, 20);
			jButtonChDispShiftUp.setToolTipText("Shift displayed channel UP (PgUp)");
			jButtonChDispShiftUp.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doChannelUp();
				}
			});
		}
		return jButtonChDispShiftUp;
	}

	/**
	 * This method initializes jButtonChDispShiftDown	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonChDispShiftDown() {
		if (jButtonChDispShiftDown == null) {
			jButtonChDispShiftDown = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/arrow_down.png")));
			jButtonChDispShiftDown.setBounds(110, 47, 20, 20);
			jButtonChDispShiftDown.setToolTipText("Shift displayed channel DOWN (PgDn)");
			jButtonChDispShiftDown.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doChannelDown();
				}
			});
		}
		return jButtonChDispShiftDown;
	}

	/**
	 * This method initializes jButtonTimeDec	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonTimeDec() {
		if (jButtonTimeDec == null) {
			jButtonTimeDec = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/arrow_left.png")));
			jButtonTimeDec.setBounds(64, 44, 20, 20);
			jButtonTimeDec.setToolTipText("Show older time (LEFT)");
			jButtonTimeDec.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doDecTime();
				}
			});
		}
		return jButtonTimeDec;
	}

	/**
	 * This method initializes jButtonTimeInc	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonTimeInc() {
		if (jButtonTimeInc == null) {
			jButtonTimeInc = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/arrow_right.png")));
			jButtonTimeInc.setBounds(92, 44, 20, 20);
			jButtonTimeInc.setToolTipText("Show later time (RIGHT)");
			jButtonTimeInc.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doIncTime();
				}
			});
		}
		return jButtonTimeInc;
	}

	/**
	 * This method initializes jButtonTimePageDec	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonTimePageDec() {
		if (jButtonTimePageDec == null) {
			jButtonTimePageDec = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/arrow2_left.png")));
			jButtonTimePageDec.setBounds(36, 44, 20, 20);
			//jButtonTimePageDec.setPreferredSize(new Dimension(20,20));
			jButtonTimePageDec.setToolTipText("Show more older time (Ctrl+LEFT)");
			jButtonTimePageDec.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doPageDecTime();
				}
			});
		}
		return jButtonTimePageDec;
	}

	/**
	 * This method initializes jButtonTimePageInc	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonTimePageInc() {
		if (jButtonTimePageInc == null) {
			jButtonTimePageInc = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/arrow2_right.png")));
			jButtonTimePageInc.setBounds(120, 44, 20, 20);
			jButtonTimePageInc.setToolTipText("Show more later time (Ctrl+RIGHT)");
			jButtonTimePageInc.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doPageIncTime();
				}
			});
		}
		return jButtonTimePageInc;
	}

	/**
	 * This method initializes jButtonZoomOut	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonZoomOut() {
		if (jButtonZoomOut == null) {
			jButtonZoomOut = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/wave-zoomout.png")));
			jButtonZoomOut.setBounds(92, 67, 20, 20);
			jButtonZoomOut.setToolTipText("Zoom out time (Ctrl+LEFT)");
			jButtonZoomOut.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doZoomOut();
				}
			});
		}
		return jButtonZoomOut;
	}

	/**
	 * This method initializes jButtonZoomIn	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonZoomIn() {
		if (jButtonZoomIn == null) {
			jButtonZoomIn = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/wave-zoomin.png")));
			jButtonZoomIn.setBounds(120, 67, 20, 20);
			jButtonZoomIn.setToolTipText("Zoom in time (Ctrl+RIGHT)");
			jButtonZoomIn.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doZoomIn();
				}
			});
		}
		return jButtonZoomIn;
	}

	/**
	 * This method initializes jComboBoxSpan	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBoxSpan() {
		if (jComboBoxSpan == null) {
			String[] comboDat = new timerange().getString();	// jve:decl-index $hide$=0: $hide$
			DefaultComboBoxModel model = new DefaultComboBoxModel(comboDat);	// jve:decl-index $hide$=0: $hide$
			jComboBoxSpan = new JComboBox(model);
			jComboBoxSpan.setBounds(7, 94, 129, 25);
			jComboBoxSpan.setToolTipText("Select time span");
			jComboBoxSpan.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
				    Object source=e.getSource();
				    if(source==jComboBoxSpan){
					    if (e.getStateChange() == ItemEvent.SELECTED){
					        String data = (String)jComboBoxSpan.getSelectedItem();
					        if(data.compareTo("-")==0) return;
					        //"1sec","2sec","3sec","10sec" ,"30sec" ,"1min" ,"3min" ,"10min" ,"30min" ,"1hour","3hour","10hour","30hour"
					        timerange tr = new timerange();
					        int sec = tr.getSec(data);
					        if(sec > 0){
					        	GraphicView.doSpan(sec);
					        	GraphicView.repaintAll();
					        }
					    }
				    }
				}
			});
		}
		return jComboBoxSpan;
	}
	public void onChangeDisplayChannel(){
		jLabelChannelInfo.setText(String.format("%d/%d",getGraphicView().getGraphNum(),getGraphicView().getChannelMax()));
	}
	

/////////////////////////////////////////////////////////////
	// 時間軸のためのサブクラス
	private class timerange{
		private int[]    tmrange   = {1,100,300,1*1000,
				2*1000,	3*1000,	10*1000,	30*1000,
				60*1*1000,	60*3*1000,	60*10*1000,	60*30*1000,
				60*60*1000,	60*60*3*1000,	60*60*12*1000,
				1*60*60*24*1000,3*60*60*24*1000,10*60*60*24*1000};
		private String[] tmrangeStr = {"-","0.1 sec","0.3 sec","1 sec",
				"2 sec",	"3 sec",	"10 sec",	"30 sec",
				"1 min",	"3 min",	"10 min",	"30 min",
				"1 hour","3 hours","12 hours",	
				"1 days", "3 days","10 days"};
		timerange(){
			
		}
		public String getString(int sec){
			int i;
			for(i=0;i<tmrange.length;i++){
				if(sec == tmrange[i]) {
					return tmrangeStr[i];
				}
			}
			return null;
		}
		public String[] getString(){
			return tmrangeStr;
		}
		public String getStringFromIndex(int index){
			if(index >= tmrange.length) return null;
			return tmrangeStr[index];
		}
		public int size(){
			return tmrange.length;
		}
		public int getSec(String str){
			int i;
			for(i=0;i<tmrangeStr.length;i++){
				if(str.compareTo(tmrangeStr[i])==0){
					return tmrange[i];
				}
			}
			return -1;
		}
		public int getIndex(String str){
			int i;
			for(i=0;i<tmrangeStr.length;i++){
				if(str.compareTo(tmrangeStr[i])==0){
					return i;
				}
			}
			return -1;
		}
		
	}


	public void onChangeTimeRange(int tm){
		String mes=new String();
		if(tm<1000) mes = String.format("%dms", tm);
		else if(tm<1000*60) mes=String.format("%5.3fsec", (double)tm/1000.0);
		else if(tm<1000*60*60) mes=String.format("%5.3fmin", (double)tm/(1000.0*60));
		else mes=String.format("%5.3fhour", (double)tm/(1000.0*60*60));
		jLabelDispSpan.setText(mes);
		timerange tr = new timerange();
		String str  = tr.getString(tm);
		int idx;
		if(str==null) idx = 0;
		else idx = tr.getIndex(str);
		jComboBoxSpan.setSelectedIndex(idx);
	}
	public void onChangeTimeStart(wintime st){
		jLabelTime.setText(st.fmt());
	}

	/**
	 * This method initializes jButtonAmpInc	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonAmpInc() {
		if (jButtonAmpInc == null) {
			jButtonAmpInc = new JButton(new ImageIcon(getClass().getClassLoader()
					.getResource("images/wave22-big.png")));
			jButtonAmpInc.setBounds(107, 52, 24, 24);
			jButtonAmpInc.setToolTipText("Amplitude Zoon IN (DOWN)");
			jButtonAmpInc.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.incDecAmplitude(true);
				}
			});
		}
		return jButtonAmpInc;
	}

	/**
	 * This method initializes jButtonAmpDec	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonAmpDec() {
		if (jButtonAmpDec == null) {
			jButtonAmpDec = new JButton(new ImageIcon(getClass().getClassLoader()
					.getResource("images/wave22-small.png")));
			jButtonAmpDec.setBounds(107, 24, 24, 24);
			jButtonAmpDec.setToolTipText("Amplitude Zoon OUT (UP)");
			jButtonAmpDec.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.incDecAmplitude(false);
				}
			});
		}
		return jButtonAmpDec;
	}

	/**
	 * This method initializes jCheckBoxOffsetZero	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	private JCheckBox getJCheckBoxOffsetZero() {
		if (jCheckBoxOffsetZero == null) {
			jCheckBoxOffsetZero = new JCheckBox();
			jCheckBoxOffsetZero.setBounds(15, 79, 110, 17);
			jCheckBoxOffsetZero.setText("Offset cancel");
			jCheckBoxOffsetZero.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					GraphicView.setAmplitudeOffset(jCheckBoxOffsetZero.isSelected());
				}
			});
		}
		return jCheckBoxOffsetZero;
	}

	/**
	 * This method initializes jButtonSnapShot	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonSnapShot() {
		if (jButtonSnapShot == null) {
			jButtonSnapShot = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/camera.png")));
			jButtonSnapShot.setPreferredSize(new Dimension(30,20));
			jButtonSnapShot.setToolTipText("Take snap shot image file in write file folder");
			jButtonSnapShot.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					String dir = GraphicView.ExportImageDir;
					if(dir == null) dir = jTextFieldWriteFileDir.getText();
					GraphicView.exportAsImage(dir,1.0,1.0);
				}
			});
		}
		return jButtonSnapShot;
	}

	/**
	 * This method initializes jButtonClear	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonClear() {
		if (jButtonClear == null) {
			jButtonClear = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/trashcan.png")));
			jButtonClear.setToolTipText("Reset Contents");
			jButtonClear.setPreferredSize(new Dimension(30,20));
			jButtonClear.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					if(JOptionPane.YES_OPTION  == JOptionPane.showConfirmDialog(null, "Dispose all data ?" ,"Dispose all data ?",JOptionPane.YES_NO_OPTION)){
						GraphicView.resetContent();
						GraphicView.repaintAll();
					}
				}
			});
		}
		return jButtonClear;
	}
	/**
	 * This method initializes jButtonChannelConfig	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonChannelConfig() {
		if (jButtonChannelConfig == null) {
			//jButtonChannelConfig = new JButton();
			jButtonChannelConfig = new JButtonWithMenu();
			jButtonChannelConfig.setBounds(7, 70, 136, 25);
			jButtonChannelConfig.setText("Config...");  // Generated
			jButtonChannelConfig.setToolTipText("Setup and configure channel property.");
			jButtonChannelConfig.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					if(jButtonChannelConfig.isClickedDropDown()){
						JPopupMenu popup=new JPopupMenu();
						JMenuItem mi = new JMenuItem("Displayed Channels");
						mi.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/display_config_table.png")));
						mi.addActionListener(new ActionListener(){
							@Override
							public void actionPerformed(ActionEvent arg0) {
								GraphicView.selectDisplayChannel(0);
							}
							
						});
				        popup.add(mi);
						JMenuItem mi2 = new JMenuItem("All Channels");
						mi2.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/view_ini.png")));
						mi2.addActionListener(new ActionListener(){
							@Override
							public void actionPerformed(ActionEvent arg0) {
								GraphicView.selectDisplayChannel(1);
							}
							
						});
				        popup.add(mi2);
				        popup.show(jButtonChannelConfig,0,jButtonChannelConfig.getHeight());
					}
					else{
						GraphicView.selectDisplayChannel(0);
					}
				}
			});
		}
		return jButtonChannelConfig;
	}
	/**
	 * This method initializes jButtonChDispPageUp	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonChDispPageUp() {
		if (jButtonChDispPageUp == null) {
			//jButtonChDispPageUp = new JButton();
			jButtonChDispPageUp = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/arrow2_up.png")));
			jButtonChDispPageUp.setBounds(77, 26, 20, 20);
			jButtonChDispPageUp.setToolTipText("Shift displayed ch Page UP (Shift+PgUp)");
			jButtonChDispPageUp.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doChannelPageUp();
				}
			});
		}
		return jButtonChDispPageUp;
	}
	/**
	 * This method initializes jButtonChDispPageDown	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonChDispPageDown() {
		if (jButtonChDispPageDown == null) {
			//jButtonChDispPageDown = new JButton();
			jButtonChDispPageDown = new JButton(new ImageIcon(getClass().getClassLoader().getResource("images/arrow2_down.png")));
			jButtonChDispPageDown.setBounds(77, 47, 20, 20);
			jButtonChDispPageDown.setToolTipText("Shift displayed ch Page DOWN (Shift+PgDn)");
			jButtonChDispPageDown.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					GraphicView.doChannelPageDown();
				}
			});
		}
		return jButtonChDispPageDown;
	}
	public void setInformation1(String info){
		jLabelInfo1.setText(info);
	}
	public void setFreeMemory(long remain,long max){
		int pct = (int)((float)remain * 100 / max);
		getPBMemory().setValue(100-pct);
		String mes = String.format("%d MB Free",remain/1024);
		getPBMemory().setToolTipText(mes);
		
		String text = String.format("Total memory %d MB", max/1024);
		if(max < 512*1024){
			labelMemory.setBackground(Color.red);
		}
		else{
			labelMemory.setBackground(Color.blue);
		}
		labelMemory.setToolTipText(text);
	}
	public void setUdpRcvStatus(int rcv,int retry,int retryrcv){
		pBUDPRcv.setValue(rcv%100);
		String mes = String.format("%d,%d/%d", rcv,retry,retryrcv);
		pBUDPRcv.setString(mes);
	}
	/**
	 * This method initializes jPanelSouth	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanelSouth() {
		if (jPanelSouth == null) {
			jLabelInfo1 = new JLabel();
			//jLabelInfo1.setPreferredSize(new Dimension(600,20));
			jPanelSouth = new JPanel();
			jPanelSouth.setBorder(new CompoundBorder());
			BorderLayout bl_jPanelSouth = new BorderLayout();
			jPanelSouth.setLayout(bl_jPanelSouth);  // Generated
			jPanelSouth.setPreferredSize(new Dimension(600, 28));
			jPanelSouth.add(getJPanelEast(), BorderLayout.EAST);  // Generated
			jPanelSouth.add(jLabelInfo1, BorderLayout.CENTER);
			jPanelSouth.add(getJPanelWest(), BorderLayout.CENTER);  // Generated
		}
		return jPanelSouth;
	}
	/**
	 * This method initializes jComboBoxDrawMode	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBoxDrawMode() {
		if (jComboBoxDrawMode == null) {
			jComboBoxDrawMode = new JComboBox();
			jComboBoxDrawMode.setBounds(6, 22, 134, 25);
			jComboBoxDrawMode.setPreferredSize(new Dimension(100,20));
			//String[] comboDat = {"Normal","Multi line","Overlapped"};	// jve:decl-index $hide$=0:
			DefaultComboBoxModel model = new DefaultComboBoxModel();	// jve:decl-index $hide$=0:
			model.addElement(new ComboLabel("Normal",new ImageIcon(getClass().getClassLoader().getResource("images/single.png"))));
			model.addElement(new ComboLabel("DrumRecorder",new ImageIcon(getClass().getClassLoader().getResource("images/multi.png"))));
			model.addElement(new ComboLabel("Overlapped",new ImageIcon(getClass().getClassLoader().getResource("images/overlapped.png"))));
			jComboBoxDrawMode.setModel(model);
			ComboCellRenderer renderer = new ComboCellRenderer();//@
			jComboBoxDrawMode.setRenderer(renderer);
			jComboBoxDrawMode.setToolTipText("Select time span");
			jComboBoxDrawMode.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
				    Object source=e.getSource();
				    if(source==jComboBoxDrawMode){
					    if (e.getStateChange() == ItemEvent.SELECTED){
					        int data = jComboBoxDrawMode.getSelectedIndex();
					        switch(data){
					        case 0:
					        	GraphicView.setGraphType(GraphicView.GRAPHIC_TYPE_NORMAL);
					        	break;
					        case 1:
				        		GraphicView.setGraphType(GraphicView.GRAPHIC_TYPE_DRUMRECORDER);
					        	break;
					        case 2:
					        	GraphicView.setGraphType(GraphicView.GRAPHIC_TYPE_NORMAL_OVERLAP);
					        	break;
					        }
					    }
				    }
				}
			});

			
			
			
			

		}
		return jComboBoxDrawMode;
	}
	
	class ComboLabel{
		  String text;
		  ImageIcon icon;
		  ComboLabel(String text, ImageIcon icon){
		    this.text = text;
		    this.icon = icon;
		  }

		  public String getText(){
		    return text;
		  }

		  public ImageIcon getIcon(){
		    return icon;
		  }
	}
	
	class ComboCellRenderer extends JLabel implements ListCellRenderer {
		@Override
		public Component getListCellRendererComponent(JList list, Object value,
				int index, boolean isSelected, boolean cellHasFocus) {
		      ComboLabel data = (ComboLabel)value;
		      setText(data.getText());
		      setIcon(data.getIcon());
			return this;
		}
	}
	/**
	 * This method initializes jPanelWest	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanelWest() {
		if (jPanelWest == null) {
			jLabelSpace = new JLabel();
			jLabelSpace.setText("   ");  // Generated
			jPanelWest = new JPanel();
			jPanelWest.setLayout(new BorderLayout(0, 0));
			jPanelWest.add(getPanel_5(), BorderLayout.WEST);
			jPanelWest.add(getJTextFieldWriteFileDir(), BorderLayout.CENTER);  // Generated
			jPanelWest.add(jLabelSpace, BorderLayout.EAST);  // Generated
		}
		return jPanelWest;
	}
	/**
	 * This method initializes jPanelEast	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	JLabel labelMemory; 
	JProgressBar pBUDPRcv;
	private JPanel panel_5;
	private JPanel getJPanelEast() {
		if (jPanelEast == null) {
			jPanelEast = new JPanel();
			jPanelEast.setLayout(new FlowLayout(FlowLayout.CENTER, 3, 2));
			
			pBUDPRcv = new JProgressBar();
			pBUDPRcv.setPreferredSize(new Dimension(100, 22));
			pBUDPRcv.setToolTipText("win UDP Status : Receive , Retry send / recv");
			//pBUDPRcv.setIndeterminate(true);
			pBUDPRcv.setStringPainted(true);
			jPanelEast.add(pBUDPRcv);
			
			labelMemory = new JLabel("Memory");
			jPanelEast.add(labelMemory);
			jPanelEast.add(getPBMemory());
			jPanelEast.add(getJButtonClear());
			jPanelEast.add(getJButtonSnapShot());  // Generated
		}
		return jPanelEast;
	}
	/* (non-Javadoc)
	 * @see wcg.winchkgPanelInterface#addMenu(javax.swing.JMenuBar)
	 */
	@Override
	public void addMenu(JMenuBar mb) {
		//
		// [File] --------------------------------------------------------------------
		// 
		JMenu menuFile = menuUtil.getMenu(mb,"File");
		if(menuFile == null){
			menuFile = menuUtil.setupMenu("File",KeyEvent.VK_F,"File",this);
			mb.add(menuFile);
		}
		// [File]-[----]
		menuFile.addSeparator();
		
		JMenuItem menuPrint = menuUtil.setupMenuItem("Print",KeyEvent.VK_P,"PrintSpectrum",this);
		menuPrint.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/printer.png")));

		menuPrint.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				PrinterJob job = PrinterJob.getPrinterJob();
				job.setPrintable(GraphicView);
				job.setJobName("winchkg");
				PageFormat page = new PageFormat();
				page.setOrientation(PageFormat.LANDSCAPE);
				Paper pp = new Paper();
				pp.setSize(210*72/25.4, 297*72/25.4);
				pp.setImageableArea(0.25*72, 0.25*72, 210*72/25.4 - 0.5*72,  297*72/25.4-0.5*72);

				page.setPaper(pp);
				job.pageDialog(page);
				if(job.printDialog()){
					try{
						job.print();
					}
					catch(Exception e){

					}
				}

			}

		});
		menuFile.add(menuPrint);

		//
		// [Data] --------------------------------------------------------------------
		// 
		JMenu timeChartData = menuUtil.getMenu(mb,"Data");
		if(timeChartData==null){
			timeChartData = menuUtil.setupMenu("Data",KeyEvent.VK_D,"Data",this);
			timeChartData.addMenuListener(this);
			mb.add(timeChartData);		
		}

		// [Data]-[----] 
		timeChartData.addSeparator();
		JMenuItem menuViewDataTable = menuUtil.setupMenuItem("Data Table View",0,"Data Table View",this);
		menuViewDataTable.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/table.png")));
		menuViewDataTable.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				getGraphicView().viewDataTable();
			}

		});
		timeChartData.add(menuViewDataTable);
		
		// [Data]-[----] 
		
		if(winchkgProperty.availableExportWin){
			timeChartData.addSeparator();
			JMenu menuExportWINA0 = menuUtil.setupMenu("Export win A0",0,"Export win A0",this);
			menuExportWINA0.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/winfile.png")));
	
			timeChartData.add(menuExportWINA0);
			{
				JMenuItem menuExportWINA0all = menuUtil.setupMenuItem("Export win A0(all)",0,"Export win A0(all)",this);
				menuExportWINA0all.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/winfile.png")));
				menuExportWINA0all.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						getGraphicView().setExportFolder(winchkgProperty.WriteFileFolder);
						getGraphicView().exportWINA0all();
					}
	
				});
				menuExportWINA0.add(menuExportWINA0all);
				
				JMenuItem menuExportWINA0disp = menuUtil.setupMenuItem("Export win A0(display range)",0,"Export win A0(display range)",this);
				menuExportWINA0disp.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/winfile.png")));
				menuExportWINA0disp.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						getGraphicView().setExportFolder(winchkgProperty.WriteFileFolder);
						getGraphicView().exportWINA0display();
					}
	
				});
				menuExportWINA0.add(menuExportWINA0disp);
			}
		}
		//-------------------------------------------
		
		
		// [Data]-[----] 
		timeChartData.addSeparator();
		JMenu menuExportCSV = menuUtil.setupMenu("Export CSV",0,"Export CSV",this);
		menuExportCSV.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/csvfile.png")));
		timeChartData.add(menuExportCSV);
		{
			JMenuItem menuExportCSVall = menuUtil.setupMenuItem("Export CSV(all)",0,"Export CSV(all)",this);
			menuExportCSVall.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/csvfile.png")));
			menuExportCSVall.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					getGraphicView().setExportFolder(winchkgProperty.WriteFileFolder);
					getGraphicView().exportCSVall();
				}

			});
			menuExportCSV.add(menuExportCSVall);
	
			JMenuItem menuExportCSVdisplay = menuUtil.setupMenuItem("Export CSV(display range)",0,"Export CSV(display range)",this);
			menuExportCSVdisplay.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/csvfile.png")));
			menuExportCSVdisplay.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					getGraphicView().setExportFolder(winchkgProperty.WriteFileFolder);
					getGraphicView().exportCSVdisplay();
				}

			});
			menuExportCSV.add(menuExportCSVdisplay);
		}

		if(winchkgProperty.availableExportBin){
			timeChartData.addSeparator();
			JMenu menuExportBin = menuUtil.setupMenu("Export Binary",0,"Export Binary",this);
			menuExportBin.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/binfile.png")));
			timeChartData.add(menuExportBin);
			{
				JMenuItem menuExportBinall = menuUtil.setupMenuItem("Export Binary(all)",0,"Export Binary(all)",this);
				menuExportBinall.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/binfile.png")));
				menuExportBinall.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						getGraphicView().setExportFolder(winchkgProperty.WriteFileFolder);
						getGraphicView().exportBinall();
					}

				});
				menuExportBin.add(menuExportBinall);
		
				JMenuItem menuExportBindisplay = menuUtil.setupMenuItem("Export Binary(display range)",0,"Export Binary(display range)",this);
				menuExportBindisplay.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/binfile.png")));
				menuExportBindisplay.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						getGraphicView().setExportFolder(winchkgProperty.WriteFileFolder);
						getGraphicView().exportBindisplay();
					}

				});
				menuExportBin.add(menuExportBindisplay);
			}
		}
		
		// [Data]-[----] 
		if(winchkgProperty.availableExportSigma){
			timeChartData.addSeparator();
			JMenu menuExportCSVSigma = menuUtil.setupMenu("Export Sigma CSV",0,"Export Sigma CSV",this);
			menuExportCSVSigma.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/exportSigma.png")));
			timeChartData.add(menuExportCSVSigma);
			
			JMenuItem menuExportCSVSigmaall = menuUtil.setupMenuItem("Export Sigma CSV(all)",0,"Export Sigma CSV(all)",this);
			menuExportCSVSigmaall.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/exportSigma.png")));
			menuExportCSVSigmaall.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					getGraphicView().setExportFolder(winchkgProperty.WriteFileFolder);
					getGraphicView().exportCSVSigmaall();
				}

			});
			menuExportCSVSigma.add(menuExportCSVSigmaall);
			// [Data]-[----] 
			JMenuItem menuExportCSVSigmaDisplay = menuUtil.setupMenuItem("Export Sigma CSV(display range)",0,"Export Sigma CSV(display range)",this);
			menuExportCSVSigmaDisplay.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/exportSigma.png")));
			menuExportCSVSigmaDisplay.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					getGraphicView().setExportFolder(winchkgProperty.WriteFileFolder);
					getGraphicView().exportCSVSigmadisplay();
				}

			});
			menuExportCSVSigma.add(menuExportCSVSigmaDisplay);
			// [Data]-[----] 
		}
		// [View]-[----] 
			
		JMenu timeChartView = menuUtil.getMenu(mb,"View");
		if(timeChartView==null){
			timeChartView = menuUtil.setupMenu("View",KeyEvent.VK_V,"View",this);
			timeChartView.addMenuListener(this);
			mb.add(timeChartView);
		}
		timeChartView.addMenuListener(this);
		
		// [View]-[----] 
		JMenu menuColor = menuUtil.setupMenu("Color",KeyEvent.VK_C,"Color",this);
		menuColor.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/rich_text_color.png")));
		timeChartView.add(menuColor);
		// [View]-[----] 

		colorColorWhite = new  JRadioButtonMenuItem("Color White background",true);
		colorColorWhite.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/wave-rd-w.png")));
		//ColorColorWhite.addItemListener(this);
		colorColorWhite.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				getGraphicView().setColorMode(GraphicView.COLOR_COLOR_WHITE_BACK);
				getGraphicView().repaintAll();		  
			}
		});
		menuColor.add(colorColorWhite);
		
		colorColorBlack = new  JRadioButtonMenuItem("Color Black background");
		colorColorBlack.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/wave-rd-b.png")));
		colorColorBlack.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				getGraphicView().setColorMode(GraphicView.COLOR_COLOR_BLACK_BACK);
				getGraphicView().repaintAll();		  
			}
		});
		menuColor.add(colorColorBlack);
		
		colorBWWhite = new  JRadioButtonMenuItem("Black&White White background");
		colorBWWhite.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/wave-b-w.png")));
		colorBWWhite.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				getGraphicView().setColorMode(GraphicView.COLOR_BW_WHITE_BACK);
				getGraphicView().repaintAll();		  
			}
		});
		menuColor.add(colorBWWhite);
		
		colorBWBlack = new  JRadioButtonMenuItem("Black&White Black background");
		colorBWBlack.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/wave-w-b.png")));
		//ColorBWBlack.addItemListener(this);
		colorBWBlack.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				getGraphicView().setColorMode(GraphicView.COLOR_BW_BLACK_BACK);
				getGraphicView().repaintAll();		  
			}
		});
		menuColor.add(colorBWBlack);
		
		ButtonGroup bg = new ButtonGroup();
		bg.add(colorColorWhite);
		bg.add(colorColorBlack);
		bg.add(colorBWWhite);
		bg.add(colorBWBlack);
		
		menuColor.addSeparator();

		colorMapByChannel = new  JRadioButtonMenuItem("Color by Channel",true);
		colorMapByChannel.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				getGraphicView().setColorCalcMode(GraphicView.COLOR_AUTO_BY_CHANNEL);
				getGraphicView().repaintAll();	
			}
		});
		menuColor.add(colorMapByChannel);

		colorMapByStation = new  JRadioButtonMenuItem("Color by Station");
		colorMapByStation.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				getGraphicView().setColorCalcMode(GraphicView.COLOR_AUTO_BY_STATION);
				getGraphicView().repaintAll();	
			}
		});
		menuColor.add(colorMapByStation);

		colorMapByComponent = new  JRadioButtonMenuItem("Color by Component");
		colorMapByComponent.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				getGraphicView().setColorCalcMode(GraphicView.COLOR_AUTO_BY_COMPONENT);
				getGraphicView().repaintAll();	
			}
		});
		menuColor.add(colorMapByComponent);
	
		ButtonGroup bg2 = new ButtonGroup();
		bg2.add(colorMapByChannel);
		bg2.add(colorMapByStation);
		bg2.add(colorMapByComponent);
		
		
		
		// [View]-[----] 
		timeChartView.addSeparator();
		showChannelInfo = new JCheckBoxMenuItem("Show m/u/@",true);
		showChannelInfo.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/u-m.png")));
		//ShowChannelInfo.addItemListener(this);
		showChannelInfo.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				boolean b = showChannelInfo.getState();	
				getGraphicView().setShowChannelInfo( b);
				getGraphicView().repaintAll();		  
			}
		});
		timeChartView.add(showChannelInfo);
		
		showChannelNumber = new JCheckBoxMenuItem("Show Channel",true);
		showChannelNumber.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/channel-name.png")));
		//ShowChannelNumber.addItemListener(this);
		showChannelNumber.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				boolean b = showChannelNumber.getState();	
				getGraphicView().setShowChannelNumber( b);
				getGraphicView().repaintAll();		  
			}
		});
		timeChartView.add(showChannelNumber);
		
		showStation = new JCheckBoxMenuItem("Show Station",true);
		showStation.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/station-name.png")));
		//ShowStation.addItemListener(this);
		showStation.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				boolean b = showStation.getState();	
				getGraphicView().setShowStation( b);
				getGraphicView().repaintAll();		  
			}
		});
		timeChartView.add(showStation);

		showComponent = new JCheckBoxMenuItem("Show Component",true);
		showComponent.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/component-name.png")));
		//ShowComponent.addItemListener(this);
		showComponent.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				boolean b = showComponent.getState();	
				getGraphicView().setShowComponent( b);
				getGraphicView().repaintAll();		  
			}
		});
		timeChartView.add(showComponent);
		
		timeChartView.addSeparator();
		
		showAmpLabel = new JCheckBoxMenuItem("Show Amplitude label",true);
		showAmpLabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/view_amp_label.png")));
		//ShowAmpLabel.addItemListener(this);
		showAmpLabel.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				boolean b = showAmpLabel.getState();	
				getGraphicView().setAmpLabelEnable( b);
				getGraphicView().repaintAll();		  
			}
		});
		timeChartView.add(showAmpLabel);

		
		showAmpAxis = new JCheckBoxMenuItem("Show Amplitude axis",true);
		showAmpAxis.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/view_amp_axis.png")));
		//ShowAmpAxis.addItemListener(this);
		showAmpAxis.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				boolean b = showAmpAxis.getState();	
				getGraphicView().setDrawYAxisLabel( b);
				getGraphicView().repaintAll();		  
			}
		});
		timeChartView.add(showAmpAxis);
		timeChartView.addSeparator();
		
		showTimeSamplePoint = new JCheckBoxMenuItem("Show Time/Sample point",true);
		showTimeSamplePoint.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/wave-timepoint.png")));
		//ShowTimeSamplePoint.addItemListener(this);
		showTimeSamplePoint.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				boolean b = showTimeSamplePoint.getState();	
				getGraphicView().setShowTimeSamplePoint( b);
				getGraphicView().repaintAll();		  
			}
		});
		timeChartView.add(showTimeSamplePoint);
		
		
		clipRect = new JCheckBoxMenuItem("Clip wave",true);
		clipRect.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/wave-clip.png")));
		//ClipRect.addItemListener(this);
		clipRect.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				boolean b = clipRect.getState();	
				getGraphicView().ClipRect=b;
				getGraphicView().repaintAll();		  
			}
		});
		timeChartView.add(clipRect);
		timeChartView.addSeparator();
		
		
		
		//--物理量表示時のフォーマット
		JMenu menuPhysicalFormat = menuUtil.setupMenu("Format for Phsical quantity",KeyEvent.VK_F,"FormatAmplitude",this);
		menuPhysicalFormat.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/PhysicalUnitFormat.png")));
		timeChartView.add(menuPhysicalFormat);
		
		if(winchkgProperty.availableTimechartManiac){
			JMenuItem menuYScaleManiacProperty =  menuUtil.setupMenuItem("XY Scale disp property",KeyEvent.VK_Y,"YScaleDispProperty",this);
			menuYScaleManiacProperty.addActionListener(new ActionListener(){
				@Override
				public void actionPerformed(ActionEvent arg0) {
					GraphicView.yAxisConf();
				}
			});
			timeChartView.add(menuYScaleManiacProperty);
		}
		
		ButtonGroup bg3 = new ButtonGroup();
		for(int k=0;k<FORMAT_AMPLITUDE_MAX;k++){
			FormatAmplitudeMenuItem[k] = new  JRadioButtonMenuItem(FormatAmplitudeString[k],false);
			//FormatAmplitude1.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/wave-rd-w.png")));
			FormatAmplitudeMenuItem[k].addItemListener(this);
			menuPhysicalFormat.add(FormatAmplitudeMenuItem[k]);
			bg3.add(FormatAmplitudeMenuItem[k]);
		}

		timeChartView.addSeparator();
		
		showCursorTime = new JCheckBoxMenuItem("Show Cursor Time",true);
		//ShowCursorTime.addItemListener(this);
		showCursorTime.addItemListener(new ItemListener(){
			@Override
			public void itemStateChanged(ItemEvent e) {
				boolean b = showCursorTime.getState();	
				GraphicView.DrawCursorTimeInfo=b;
				GraphicView.repaintAll();		  
			}
		});
		timeChartView.add(showCursorTime);
		
	}
	/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		int kkk = isFormatChangeEvent(e);
		if(kkk>=0){
			getGraphicView().setPhysicalQuantityFormat(FormatAmplitudeFormat[kkk]);
			getGraphicView().repaintAll();		  
		}
	}
	/* (non-Javadoc)
	 * @see javax.swing.event.MenuListener#menuCanceled(javax.swing.event.MenuEvent)
	 */
	@Override
	public void menuCanceled(MenuEvent e) {
		
	}
	/* (non-Javadoc)
	 * @see javax.swing.event.MenuListener#menuDeselected(javax.swing.event.MenuEvent)
	 */
	@Override
	public void menuDeselected(MenuEvent e) {
		
	}
	/* (non-Javadoc)
	 * @see javax.swing.event.MenuListener#menuSelected(javax.swing.event.MenuEvent)
	 */
	@Override
	public void menuSelected(MenuEvent e) {
		JMenu menu = (JMenu)e.getSource();
		String cmd = menu.getActionCommand();
		if(cmd.compareToIgnoreCase("VIEW")==0){
			if(showChannelInfo!=null){
				showChannelInfo.setSelected(getGraphicView().isShowChannelInfo());
			}
			if(showChannelNumber != null){
				showChannelNumber.setSelected(getGraphicView().getShowChannelNumber());
			}
			if(showStation!=null){
				showStation.setSelected(getGraphicView().getShowStation());
			}
			if(showComponent !=null){
				showComponent.setSelected(getGraphicView().getShowComponent());
			}

			if(showTimeSamplePoint != null){
				showTimeSamplePoint.setSelected(getGraphicView().getShowTimeSamplePoint());
			}
			
			boolean drawYaxis = getGraphicView().getDrawYAxisLabel();
			showAmpAxis.setSelected(drawYaxis);
			if(drawYaxis){
				showAmpLabel.setEnabled(true);
				showAmpLabel.setSelected(getGraphicView().getAmpLabelEnable());
			}
			else{
				showAmpLabel.setEnabled(false);
			}
			
			if(clipRect!=null) {
				clipRect.setSelected(getGraphicView().ClipRect);
			}
			if(showCursorTime != null){
				showCursorTime.setSelected(getGraphicView().DrawCursorTimeInfo);
			}
			
			int colormode = getGraphicView().getColorMode(); 
			if(colormode == GraphicView.COLOR_BW_BLACK_BACK){
				colorBWBlack.setSelected(true);
			}
			else if(colormode == GraphicView.COLOR_BW_WHITE_BACK){
				colorBWWhite.setSelected(true);
			}
			else if(colormode == GraphicView.COLOR_COLOR_BLACK_BACK){
				colorColorBlack.setSelected(true);
			}
			else if(colormode == GraphicView.COLOR_COLOR_WHITE_BACK){
				colorColorWhite.setSelected(true);
			}
			
			colormode = getGraphicView().getColorCalcMode(); 
			if(colormode == GraphicView.COLOR_AUTO_BY_CHANNEL){
				colorMapByChannel.setSelected(true);
			}
			else if(colormode == GraphicView.COLOR_AUTO_BY_STATION){
				colorMapByStation.setSelected(true);
			}
			else if(colormode == GraphicView.COLOR_AUTO_BY_COMPONENT){
				colorMapByComponent.setSelected(true);
			}
			
			// 白黒モードのときはディゼーブルにする
			if(colormode == GraphicView.COLOR_BW_BLACK_BACK || colormode == GraphicView.COLOR_BW_WHITE_BACK){
				colorMapByChannel.setEnabled(false);
				colorMapByStation.setEnabled(false);
				colorMapByComponent.setEnabled(false);
			}
			else{
				colorMapByChannel.setEnabled(true);
				colorMapByStation.setEnabled(true);
				colorMapByComponent.setEnabled(true);
			}
			//----------------------------------------------------
			String fmt = getGraphicView().getPhysicalQuantityFormat();
			int n = getPhysicalFormatIndex(fmt);
			if(n>=0){
				FormatAmplitudeMenuItem[n].setSelected(true);
			}
			
		}
	}
	/* (non-Javadoc)
	 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
	 */
	@Override
	public void itemStateChanged(ItemEvent e) {
		
		int kkk = isFormatChangeEvent(e);
		if(kkk>=0){
			getGraphicView().setPhysicalQuantityFormat(FormatAmplitudeFormat[kkk]);
			getGraphicView().repaintAll();		  
		}

	}
	
	private int getPhysicalFormatIndex(String fmt){
		int i=0;
		for(;i<FORMAT_AMPLITUDE_MAX;i++ ){
			if(FormatAmplitudeFormat[i].compareTo(fmt) == 0){
				return i;
			}
		}
		return -1;
	}
	private int isFormatChangeEvent(ActionEvent arg0){
		int i=0;
		for(;i<FORMAT_AMPLITUDE_MAX;i++ ){
			if(arg0.getSource()== FormatAmplitudeMenuItem[i]){
				return i;
			}
		}
		return -1;
	}
	private int isFormatChangeEvent(ItemEvent arg0){
		int i=0;
		for(;i<FORMAT_AMPLITUDE_MAX;i++ ){
			if(arg0.getSource()== FormatAmplitudeMenuItem[i]){
				return i;
			}
		}
		return -1;
	}
	private JPanel getPanel_4() {
		if (panel_4 == null) {
			panel_4 = new JPanel();
			panel_4.setBorder(new TitledBorder(null, "win UDP", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			panel_4.setBounds(1, 510, 145, 82);
			panel_4.setLayout(null);
			panel_4.add(getJCheckBoxRcvUdp());
			jLabelPort = new JLabel();
			jLabelPort.setBounds(15, 50, 33, 19);
			panel_4.add(jLabelPort);
			jLabelPort.setText("Port");
			panel_4.add(getJTextFieldPort());
		}
		return panel_4;
	}
	private JProgressBar getPBMemory() {
		if (pBMemory == null) {
			pBMemory = new JProgressBar();
			pBMemory.setPreferredSize(new Dimension(20, 22));
			pBMemory.setOrientation(SwingConstants.VERTICAL);
		}
		return pBMemory;
	}
	/**
	 * @param imp
	 */
	private boolean doMyScale(String imp) {
		String[] tok = imp.split(" ");
		if(tok.length == 1){
			long val = Long.valueOf(tok[0]);
			if(val<=0){
				return false;
			}
			GraphicView.doSingleScale(val);
		}
		else if(tok.length == 2){
			double val = Double.valueOf(tok[0]);
			if(val<=0.0){
				return false;
			}
			GraphicView.doSingleScale(tok[1],val);
		}
		else {
			return false;
		}
		return true;
	}
	private JPanel getPanel_5() {
		if (panel_5 == null) {
			panel_5 = new JPanel();
			panel_5.setLayout(new GridLayout(0, 1, 0, 0));
			panel_5.add(getJCheckBoxWriteFile());
		}
		return panel_5;
	}
}

